
package com.kanjian.music.adapter;

import java.util.ArrayList;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

public class MusicControlerPagerAdapter extends FragmentPagerAdapter {

    ArrayList<Fragment> mFragmentList;

    public MusicControlerPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public MusicControlerPagerAdapter(FragmentManager fm, ArrayList<Fragment> list) {
        super(fm);
        this.mFragmentList = list;
    }

    public void setFragmentList(ArrayList<Fragment> mList) {
        if (mFragmentList == null) {
            mFragmentList = new ArrayList<Fragment>();
        } else {
            this.mFragmentList.clear();
        }
        this.mFragmentList.addAll(mList);
        this.notifyDataSetChanged();
    }

    @Override
    public void setPrimaryItem(ViewGroup container, int position, Object object) {
        super.setPrimaryItem(container, position, object);
    }

    @Override
    public Fragment getItem(int arg0) {
        return mFragmentList != null ? mFragmentList.get(arg0) : null;
    }

    @Override
    public int getCount() {
        return mFragmentList != null ? mFragmentList.size() : 0;
    }
    
}
